<template>
  <el-dialog
    title="提示"
    :visible.sync="showDiaLog"
    width="600px"
    :append-to-body="true"
    :close-on-click-modal="false"
  >
    <h3 style="text-align: center" v-if="row">
      {{ row.companyName }}，是否通过审核？
    </h3>
    <el-input
      v-model.trim="remarks"
      type="textarea"
      :rows="3"
      placeholder="请输入备注"
    />

    <div slot="footer" class="dialog-footer">
      <el-button @click="trial(2)" :loading="loading">不通过</el-button>
      &nbsp;
      <el-button type="primary" @click="trial(1)" :loading="loading">
        通过
      </el-button>
    </div>
  </el-dialog>
</template>
<script>
// 引入方审核
export default {
  name: 'trial',
  data () {
    return {
      showDiaLog: false,
      remarks: '',
      row: null,
      loading: false
    }
  },
  methods: {
    show (row) {
      this.row = row
      this.remarks = ''
      this.loading = false
      this.showDiaLog = true
    },
    trial (auditStatus) {
      if (auditStatus == 2 && this.remarks == '') {
        this.$swal.error('请输入备注')
        return
      }
      this.loading = true
      this.$POST('sot-admin-api/company/audit', {
        id: this.row.companyId,
        auditReason: this.remarks,
        auditStatus
      })
        .then(res => {
          if (res.errorCode == '00000') {
            this.$swal.success('审核成功')
            this.showDiaLog = false
            this.$emit('trialSuccess')
          } else {
            this.$swal.success(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        })
    }
  }
}
</script>
